* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;  /* 增加容器最大宽度 */
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 角色选择 */
.character-selection {
    background: white;
    border-radius: 15px;
    padding: 40px;  /* 增加内边距 */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%;    /* 使用全宽度 */
}

.character-selection h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #4a5568;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.character-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.character-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.character-card h3 {
    color: #2d3748;
    margin-bottom: 8px;
    font-size: 1.3rem;
}

.character-card p {
    color: #718096;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* 聊天界面 */
.chat-container {
    background: white;
    border-radius: 15px;
    padding: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.character-info {
    display: flex;
    align-items: center;
}

.character-info img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 15px;
    background: white;
    padding: 5px;
}

.character-info h3 {
    margin-bottom: 5px;
    font-size: 1.3rem;
}

.character-info p {
    opacity: 0.9;
    font-size: 0.9rem;
}

.back-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 80%;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.assistant {
    align-self: flex-start;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: #667eea;
    color: white;
}

.message-content {
    background: #f7fafc;
    padding: 12px 18px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-content {
    background: #667eea;
    color: white;
}

.message.assistant .message-content {
    background: #e2e8f0;
    color: #2d3748;
}

.welcome-message {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #e6fffa 0%, #f0fff4 100%);
    border-radius: 12px;
    color: #2d5016;
    margin-bottom: 20px;
}

/* 输入控件 */
.chat-input-container {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    background: #f8f9fa;
    border-radius: 0 0 15px 15px;
}

.input-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 10px;
}

.voice-btn {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.voice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.4);
}

.voice-btn.recording {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    animation: pulse 2s infinite;
}

.text-input-group {
    display: flex;
    flex: 1;
    gap: 10px;
}

#textInput {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

#textInput:focus {
    outline: none;
    border-color: #667eea;
}

#sendTextBtn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 18px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease;
}

#sendTextBtn:hover {
    background: #5a5fcf;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
}

#playResponseBtn {
    background: linear-gradient(135deg, #9f7aea 0%, #805ad5 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#playResponseBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(159, 122, 234, 0.4);
}

/* 录音指示器 */
.recording-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 40px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1000;
}

.pulse {
    width: 20px;
    height: 20px;
    background: #e53e3e;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

/* 加载状态 */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

/* 动画 */
@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .character-grid {
        grid-template-columns: 1fr;
    }

    .chat-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .input-controls {
        flex-direction: column;
        gap: 10px;
    }

    .voice-btn {
        width: 100%;
        justify-content: center;
    }

    .message {
        max-width: 95%;
    }
}

/* 消息动画 */
.message {
    opacity: 0;
    transform: translateY(20px);
    animation: messageAppear 0.5s ease forwards;
}

@keyframes messageAppear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}